import Taro from '@tarojs/taro';
import  { Component } from 'react'

import { View, Text, Image } from '@tarojs/components';
import './panel.less';
import { myTimeToLocal } from '../../utils/date';

class Panel extends Component {
   toDetail(item) {
      Taro.navigateTo({ url: '/detail/pages/detail/detail?topicId=' + item.id })
   }

   render() {
      // @ts-ignore
     let { listData, title } = this.props;
      return (
         <View className='topic-panel'>
            <View className='topic-panel-title'>{title}</View>
            {listData.map((item) => {
               return (<View onClick={()=>this.toDetail(item)} className='topic-panel-list' key={item.id}>
                  <Image className='topic-panel-list-img' src={item.author.avatar_url} />
                  <Text className='topic-panel-list-title'>{item.title}</Text>
                  <Text className='topic-panel-list-date'>{myTimeToLocal(item.last_reply_at)}</Text>
               </View>)
            })
            }
         </View>
      )
   }
}
export default Panel;
